﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dreamz
{
    public class Rum1
    {    
        public static void Apply()
        {
           //Adds methods that are invoked upon looking at the object text, or leaving the room.
            GameEngine.S.World[2, 1].Items["writing"].OnLook += new EventHandler(LookWriting);
            GameEngine.S.World[2, 1].OnLeave += new Room.OnLeaveHandler(LeaveRoom);

        }
        public static void LookWriting()
        {
           //Confirms that the player has read the text through a boolean.
            GameEngine.GameState.HasLooked = true;
        }
        public static void LeaveRoom(Direction direction)
        {
           //Cehcks that the player have looked at the text, and that they are leaving east. If those conditions are met, the program
           //sends a message saying that the roof have fallen down in the room just left, changes all descriptions which covers the path, and closes the way.
           //Also resets the variables used.
            if (GameEngine.GameState.HasLooked == true && direction == Direction.East)
            {
                GameEngine.S.World[3, 1].West = false;
                GameEngine.S.World[3,1].Items["corridor"].Description=@"The corridor streatches north and east as far as the eye can see. 
To the west, there's only rubble.";
                GameEngine.GameState.HasLooked = false;
                UI.Console.Clear();
                UI.Draw();
                UI.Console.Write("The Roof of the dead end suddenly collapses, there is no way you are getting back there.\n\n");
                UI.Draw();
                Console.ReadKey();
            }
        }

    }
}